#!/usr/bin/env python

import wx
import component

class Main(component.Interactor):
    '''Main class
    
    @author Julot <andy.julot@gmail.com>
    @since Saturday, January 14, 2012. 09:04 AM'''
    
    def bind(self):
        super(Main, self).bind()
        
        view = self.view
        menu = view.MenuBar
        tool = view.ToolBar
        
        view.Bind(wx.EVT_MENU, self.close, menu.file.close)
        view.Bind(wx.EVT_MENU, self.showAbout, menu.help.about)
        view.Bind(wx.EVT_MENU, self.browse, menu.doc.browse)
        view.Bind(wx.EVT_MENU, self.update, menu.doc.update)
        
        view.Bind(wx.EVT_MENU, self.close, tool.close.tool)
        view.Bind(wx.EVT_MENU, self.showAbout, tool.about.tool)
        view.Bind(wx.EVT_MENU, self.browse, tool.browse.tool)
        view.Bind(wx.EVT_MENU, self.update, tool.update.tool)
        
        view.Bind(wx.EVT_LIST_ITEM_SELECTED, self.show, view.files)
        view.image.Bind(wx.EVT_LEFT_DOWN, self.startFile)
        
    def close(self, event):
        self.presenter.close()
        event.Skip()
    
    def showAbout(self, event):
        self.presenter.showAbout()
        event.Skip()
        
    def update(self, event):
        self.presenter.update()
        event.Skip()
    
    def browse(self, event):
        self.presenter.browse()
        event.Skip()
        
    def show(self, event):
        self.presenter.show(self.view.files.values[event.Data])
        event.Skip()
    
    def startFile(self, event):
        self.presenter.startFile()
        event.Skip()